package vip.xiaonuo.device.modular.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.device.modular.entity.BizGoods;
import vip.xiaonuo.device.modular.entity.DevDict;
import vip.xiaonuo.device.modular.entity.SysUser;
import vip.xiaonuo.device.modular.service.DeviceApiService;
import vip.xiaonuo.device.vo.*;

import javax.annotation.Resource;

@Slf4j
@Api(value = "柜子屏", tags = {"柜子屏相关接口"})
@ApiSupport(author = "kongxm", order = 1)
@RestController
@Validated
@RequestMapping("/api/cabinet")
public class DeviceCabinetInfoController {
    @Resource
    private DeviceApiService deviceCabinetInfoService;

    @Resource
    private DeviceApiService deviceCabinetDoorService;

    @Resource
    private DeviceApiService deviceGoodsPageService;

    @Resource
    private DeviceApiService deviceGoodsService;

    @Resource
    private DeviceApiService deviceGoodsLedgerService;

    @Resource
    private DeviceApiService deviceCabinetAdminService;

    @Resource
    private DeviceApiService deviceCabinetContactService;

    @Resource
    private DeviceApiService deviceReagentClassService;

    @Resource
    private DeviceApiService devDictService;
    @Resource
    private DeviceApiService deviceGoodsAddService;


    @ApiOperationSupport(order = 1)
    @PostMapping("/list")
    @ApiOperation(value = "柜子详情（首页）", notes = "参数:cabinetId", response = CabinetInfoVO.class)
    public Result queryCabinetList(@RequestBody String jsonStr) {
        return deviceCabinetInfoService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 2)
    @PostMapping("/getDoorInfo")
    @ApiOperation(value = "柜门信息", notes = "参数:cabinetDoorId", response = CabinetScreenDoorVO.class)
    public Result queryCabinetDoor(@RequestBody String jsonStr) {
        return deviceCabinetDoorService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 3)
    @PostMapping("/getPageGoodsByDoor")
    @ApiOperation(value = "物品列表", notes = "参数:cabinetDoorId/current/size", response = CabinetScreenGoodsPageVO.class)
    public Result getPageGoodsByDoor(@RequestBody String jsonStr) {
        return deviceGoodsPageService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 4)
    @PostMapping("/getGoodsInfo")
    @ApiOperation(value = "物品详情", notes = "参数:cabinetDoorId/goodsId", response = CabinetScreenGoodsVO.class)
    public Result getGoodsInfo(@RequestBody String jsonStr) {
        return deviceGoodsService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 5)
    @PostMapping("/getGoodsLedgerList")
    @ApiOperation(value = "物品台账", notes = "参数:cabinetDoorId", response = CabinetScreenGoodsLedgerVO.class)
    public Result getGoodsLedgerList(@RequestBody String jsonStr) {
        return deviceGoodsLedgerService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 6)
    @PostMapping("/getCabAdminList")
    @ApiOperation(value = "柜子管理员", notes = "参数:cabinetGroupId/cabinetId", response = CabinetScreenAdminVO.class)
    public Result getCabAdminList(@RequestBody String jsonStr) {
        return deviceCabinetAdminService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 7)
    @PostMapping("/getCabContactList")
    @ApiOperation(value = "柜子联系人", notes = "参数:cabinetId", response = CabinetContactVO.class)
    public Result getCabContactList(@RequestBody String jsonStr) {
        return deviceCabinetContactService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 8)
    @PostMapping("/getReagentClassList")
    @ApiOperation(value = "试剂类型列表", notes = "参数:casNo", response = ReagentClassVO.class)
    public Result getReagentClassList(@RequestBody String jsonStr) {
        return deviceReagentClassService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 9)
    @PostMapping("/geDictList")
        @ApiOperation(value = "字典列表", notes = "参数:dictValue[存放试剂类型:REAGENT_STORAGE_TYPE,试剂形态:REAGENT_FORM_TYPE,试剂氧化还原类型:REAGENT_REDOX_TYPE,试剂瓶类型:REAGENT_BOTTLE_TYPE]", response = DevDict.class)
    public Result geDictList(@RequestBody String jsonStr) {
        return devDictService.execute(jsonStr);
    }

    @ApiOperationSupport(order = 10)
    @PostMapping("/addReagent")
    @ApiOperation(value = "试剂添加", notes = "示例[字段说明同返回类]:{\n" +
            "    \"data\":{\n" +
            "        \"goodsName\":\"水\",\n" +
            "        \"rfidNum\":\"7777123\",\n" +
            "        \"maxLimitLeave\":\"10\",\n" +
            "        \"maxLimitLeaveUnit\":\"1\",\n" +
            "        \"bizReagentClassId\":\"1646435965831434242\",\n" +
            "        \"reagentCasNo\":\"7732-18-5\",\n" +
            "        \"reagentInitNetAmount\":\"100.02\",\n" +
            "        \"reagentDensity\":\"10\",\n" +
            "        \"reagentUnit\":\"1\",\n" +
            "        \"reagentFormId\":\"solid\",\n" +
            "        \"reagentClassId\":\"POISION\",\n" +
            "        \"reagentRedoxClassId\":\"oxidant\",\n" +
            "        \"reagentBottleType\":\"metal\",\n" +
            "        \"reagentMaxErrorValue\":\"5\",\n" +
            "        \"reagentValidityPeriod\":\"2023-12-31\"\n" +
            "    },\n" +
            "    \"timestamp\":1684372927632,\"sign\":\"7363A5379F979C7D\"\n" +
            "}", response = BizGoods.class)
    public Result addReagent(@RequestBody String jsonStr) {
        return deviceGoodsAddService.execute(jsonStr);
    }
}
